package com.example.okhttputils.mvp.base;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;

import androidx.multidex.BuildConfig;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.alibaba.android.arouter.launcher.ARouter;


/**
 * @author:created by njb
 * 时间:2019/3/8 15 03
 * 描述:
 */
public class App extends MultiDexApplication {
    //全局Context
    private static Context sContext;
    private static App mInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        sContext =  getApplicationContext();
        initconfig();
        if(BuildConfig.DEBUG){
            ARouter.openLog();
            ARouter.openDebug();
        }
        ARouter.init(this);
    }


    public App() {
        mInstance = this;
    }

    public static Context getContext() {
        return sContext;
    }

    public static App the() {
        return mInstance;
    }



    /**
     * 设置APP应用字体不缩放
     */
    private void initconfig() {
        Resources res = super.getResources();
        Configuration config = new Configuration();
        config.setToDefaults();
        res.updateConfiguration(config, res.getDisplayMetrics());
    }



    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

}
